<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:t="http://myfaces.apache.org/tomahawk"
				template="/pages/crud_template.xhtml"> 

	<ui:param name="crudBean" value="#{empresaBean}" />
	
	<ui:define name="requiredFieldsMessage">
		<h:outputText value="#{bundle.todosCamposObrigatorios}" rendered="#{crudBean.updating}"/>
	</ui:define>
	
	<ui:define name="content">
		<!-- Painel de Pesquisa - Inicio -->
		<h:panelGroup id="panelGroupDePesquisa" rendered="#{crudBean.searching}">
			<f:subview id="viewBusca">
				<table>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_codigo}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.codigo}" size="30" maxlength="12" onkeypress="soNumeroEVirgula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_cnpj}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.cnpj}" maxlength="18" onkeypress="soNumero(this);" onkeyup="formataCNPJ(this,event);" onblur="completaCNPJ(this);"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.descricao}" size="60" maxlength="50" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome_reduzido}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.descricaoReduzida}" size="60" maxlength="20" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_flag_integracao}"/></td>
						<td class="tdBranco"> 
							<table style="width: 200px;">
								<tr>
									<td>
										<h:selectOneRadio value="#{crudBean.searchObject.flagIntegracao}">
			   							   <f:selectItem itemValue="T" itemLabel="#{bundle.lbl_todos}"/>   
										   <f:selectItem itemValue="S" itemLabel="#{bundle.lbl_sim}"/>   
										   <f:selectItem itemValue="N" itemLabel="#{bundle.lbl_not}"/>  
										</h:selectOneRadio>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Pesquisa - Fim -->
		
		<!-- Painel de Cadastro - Inicio -->
		<h:panelGroup id="panelGroupDeCadastro" rendered="#{crudBean.updating}">
			<f:subview id="viewCadastro">
				<table>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.descricao}" size="60" maxlength="50" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome_reduzido}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.descricaoReduzida}" size="60" maxlength="20" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_cnpj}"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.cnpj}" maxlength="18" onkeypress="soNumero(this);" onkeyup="formataCNPJ(this,event);" onblur="completaCNPJ(this);"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_flag_integracao}"/></td>
						<td class="tdBranco"> 
							<table style="width: 200px;">
								<tr>
									<td>
										<h:selectOneRadio value="#{crudBean.entity.flagIntegracao}">
										   <f:selectItem itemValue="S" itemLabel="#{bundle.lbl_sim}"/>   
										   <f:selectItem itemValue="N" itemLabel="#{bundle.lbl_not}"/>  
										</h:selectOneRadio>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Cadastro - Fim -->

		<!-- Painel de Visualizar - Inicio -->
		<h:panelGroup id="panelGroupDeView" rendered="#{crudBean.viewing}">
			<f:subview id="viewVisualizar">
				<table>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_codigo}"/> </td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.codigo}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome}"/> </td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.descricao}" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_nome_reduzido}"/> </td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.descricaoReduzida}" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_cnpj}"/> </td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.cnpj}" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_flag_integracao}"/></td>
						<td class="tdBranco"> 
							<h:outputText value="#{crudBean.entity.flagIntegracao}" />
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Visualizar - Fim -->
		
	</ui:define>
	
	<ui:define name="list">
		<h:panelGroup id="panelGroupDeListagem" rendered="#{crudBean.searching}">
			<f:subview id="viewListagem">
				<rich:dataTable id="tblData" value="#{crudBean.searchResult}" binding="#{crudBean.tblData}" var="rst" style="width: 100%;" rowClasses="par,impar">
               		
               		<rich:column style="text-align: right;" sortBy="#{rst.codigo}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_codigo}" />
						</f:facet>
						<h:outputText value="#{rst.codigo}"/>
					</rich:column>
               		<rich:column style="text-align: left;" sortBy="#{rst.descricao}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_nome}" />
						</f:facet>
						<h:outputText value="#{rst.descricao}"/>
					</rich:column>
               		<rich:column style="text-align: left;" sortBy="#{rst.descricaoReduzida}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_nome_reduzido}" />
						</f:facet>
						<h:outputText value="#{rst.descricaoReduzida}"/>
					</rich:column>
               		<rich:column style="text-align: right;" sortBy="#{rst.cnpj}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_cnpj}" />
						</f:facet>
						<h:outputText value="#{rst.cnpj}"/>
					</rich:column>
               		<rich:column style="text-align: center;" sortBy="#{rst.flagIntegracao}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_flag_integracao}" />
						</f:facet>
						<h:outputText value="#{rst.flagIntegracao}"/>
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<a4j:commandLink actionListener="#{crudBean.exibirSelecionado}" ajaxSingle="true" reRender="formulario, panelTitle">
							<h:graphicImage title="visualizar" value="/imagens/lupa.jpg" style="border: 0px;"/>
						</a4j:commandLink>
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<a4j:commandLink actionListener="#{crudBean.preparaAlterar}" ajaxSingle="true" reRender="formulario, panelTitle">
							<h:graphicImage title="alterar" value="/imagens/alterar.gif" style="border: 0px;"/>
						</a4j:commandLink>
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<t:commandLink action="#{matrizBean.preparaPesquisar}" value="#{bundle.lbl_matriz}">
							<t:updateActionListener  property="#{matrizBean.entity.empresaVo}" value="#{rst}"/>
						</t:commandLink>					
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<t:commandLink action="#{estabelecimentoBean.preparaPesquisar}" value="#{bundle.lbl_estabelecimento}">
							<t:updateActionListener  property="#{estabelecimentoBean.entity.estEmpresaVo}" value="#{rst}"/>
						</t:commandLink>					
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<t:commandLink action="#{lojaBean.preparaPesquisar}" value="#{bundle.lbl_loja}">
							<t:updateActionListener  property="#{lojaBean.entity.estEmpresaVo}" value="#{rst}"/>
						</t:commandLink>					
					</rich:column>
				   
				</rich:dataTable>
			</f:subview>
		</h:panelGroup>
	</ui:define>
	
</ui:composition>